import pandas as pd
import numpy as np
import seaborn as sn
import matplotlib.pyplot as plt


pd.set_option('display.width',1000)
pd.set_option('display.max_rows',500)
pd.set_option('display.max_columns',500)

df=pd.read_csv("./Bike-Sharing-Dataset/day.csv")
print(df.head())
df.info()
'对数据值型特征，用常用统计量观察其分布'
'数据量、均值、方差、最大值、最小值'
print(df.describe())

'对类别型特征观察其取值范围或直方图'

category_feature=['season','mnth','weathersit','weekday']
for col in category_feature:
    print('\n%s属性取不同值时出现的次数'% col)
    print(df[col].value_counts())
    df[col]=df[col].astype('object')

'对数值型特征，直方图'
number_feature=['temp','atemp','hum','windspeed']
df[number_feature].hist()
plt.show()

"""特征与目标之间的关系"""
feature=['yr','cnt']
sn.violinplot(data=df[feature],x='yr',y='cnt')
plt.show()

"""一年中每一天的骑行量"""
df['date']=pd.to_datetime(df['dteday'])
df['dayofyear']=df['date'].dt.dayofyear

fig,ax=plt.subplots()
feature=['dayofyear','cnt','yr']
sn.pointplot(data=df[feature],x='dayofyear',y='cnt',hue='yr',ax=ax)
ax.set(title="display distribution of counts")
plt.show()

"""季节与骑行量的关系"""
feature=['season','cnt']
sn.violinplot(data=df[feature],x='season',y='cnt')
plt.show()

fig,ax=plt.subplots()
sn.barplot(data=df[feature],x='season',y='cnt')
ax.set(title='Seasonly distribution of counts')
plt.show()

"""月份与骑行量的关系"""
fig,ax=plt.subplots()
sn.barplot(data=df[['mnth','cnt']],x='mnth',y='cnt')
ax.set(title='Monthly distribution of counts')
plt.show()